home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AOL File Library: 2,801 to 2,900
/
aol-file-protocol-4400-2801-to-2900.zip
/
AOLDLs
/
C++ Files Library
/
C++ Direct Buffer Access Code
/
Blitting.sit
/
Blitting Folder ƒ
/
PUT IN--“Metrowerks C_C++” ƒ
/
Personal Library
/
MacintoshIdioms.h
next >
Wrap
Text File
|
1995-08-04
|
1KB
|
75 lines
// MacintoshIdioms.h, common pieces of code in the form of inline-functions
// copyright ⌐ 1995, Macneil Shonle. All rights reserved.
#ifndef __MACINTOSHIDIOMS__
#define __MACINTOSHIDIOMS__
inline void ButtonDelay(int waitMouseUp =true)
{
while (!::Button()) ;
if (waitMouseUp) while (::Button()) ;
}
inline void Delay(long howLong)
{
long dummy;
::Delay(howLong, &dummy);
}
inline Point& TopLeft(Rect& r)
{
return ((Point*)&r)[0];
}
inline Point& BottomRight(Rect& r)
{
return ((Point*)&r)[1];
}
inline void CenterRect(Rect& rect, const Rect& frame)
{
::OffsetRect(&rect, -rect.left, -rect.top);
::OffsetRect(&rect, (frame.right - frame.left - rect.right)/2,
(frame.bottom - frame.top - rect.bottom)/2);
}
inline Point MakePoint(short h, short v)
{
Point pt = {v, h};
return pt;
}
inline Rect MakeRect(short left, short top, short bottom, short right)
{
Rect r = {top, left, right, bottom};
return r;
}
// class LittleTimer
class LittleTimer {
public:
LittleTimer() : startTime(::TickCount()), frames(0) {}
~LittleTimer()
{
long totalTime = ::TickCount() - startTime;
totalTime /= 60;
if (totalTime) {
Str255 string;
::NumToString(frames/totalTime, string);
::DebugStr(string);
}
else
::DebugStr("\pNot enough timed");
}
long operator++(int)
{
return frames++;
}
private:
long startTime;
long frames;
};
#endif